import { Util } from '@ibizstudio/runtime';

export class ModelData {
    /**
     * 临时唯一标识
     *
     * @type {string}
     * @memberof ModelData
     */
    uuid: string = Util.createUUID();
    /**
     * 创建时间
     *
     * @type {string}
     * @memberof ModelData
     */
    createdDate: string = new Date().toLocaleString(undefined, { hour12: false });
    /**
     * 呈现标题
     *
     * @type {string}
     * @memberof ModelData
     */
    title: string;
    /**
     * 是否已经导出模型至当前数据
     *
     * @type {boolean}
     * @memberof ModelData
     */
    isExport: boolean = false;
    /**
     * 是否导出报错
     *
     * @type {boolean}
     * @memberof ModelData
     */
    isError: boolean = false;
    /**
     * 导出异常时的错误信息
     *
     * @type {string}
     * @memberof ModelData
     */
    errorInfo?: string;
    /**
     * 实体名称
     *
     * @type {string}
     * @memberof ModelData
     */
    srfDeName: string;
    /**
     * 父数据
     *
     * @type {*}
     * @memberof ModelData
     */
    srfParentData?: any;
    /**
     * 拷贝源数据
     *
     * @type {any[]}
     * @memberof ModelData
     */
    items: any[] = [];
    /**
     * 导出的模型
     *
     * @type {any[]}
     * @memberof ModelData
     */
    models: any[] = [];

    /**
     * Creates an instance of ModelData.
     * @param {{ title: string, srfDeName: string, srfParentData?: any, items: any[] }} data
     * @memberof ModelData
     */
    constructor(data: { title: string, srfDeName: string, srfParentData?: any, items: any[] }) {
        this.title = data.title;
        this.srfDeName = data.srfDeName;
        if (data.items) {
            this.items = data.items;
        }
        if (data.srfParentData) {
            this.srfParentData = data.srfParentData;
        }
    }
}